package py.com.erpone.view.converter;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.inject.Inject;
import javax.inject.Named;

import py.com.erpone.entity.dm.Presentacion;
import py.com.erpone.session.dm.list.PresentacionList;

@Named
public class PresentacionConverter implements Converter{
	
	
	@Inject
	private PresentacionList presentacionList;
	
	

	@Override
	public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2) {
		return presentacionList.findById(Long.parseLong(arg2));
	}

	@Override
	public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2) {
		if(arg2==null || ((Presentacion)arg2).getId()==null)
			return "";
		return ((Presentacion)arg2).getId().toString();
	}

}
